//
// Created by 123 on 2024/12/26.
//
#include <stdio.h>
#include <stdlib.h>

int* createArray(int size){
    int* arr = (int*)malloc(size* sizeof(int));
    if(arr == NULL){
        printf("内存分配失败\n");
        exit(1);
    }
    //初始化数组
    for (int i = 0; i < size; ++i) {
        arr[i] = i*10;
    }
    return arr;
}

int main057(void){
    int size = 5;
    int* myArray = createArray(size);
    for (int i = 0; i < size; ++i) {
        printf("myArray[%d]==%d\n",i,myArray[i]);
    }
    //释放动态分配的内存
    free(myArray);
    return 0;
}